package org.darkforest.common.services.impl;

import org.darkforest.common.services.StatOrderGoodsService;
import org.darkforest.dao.mapper.OrderStatisticsMapper;
import org.darkforest.dao.mapper.StatOrderGoodsMapper;
import org.darkforest.dao.mapper.StatisticsEntryMapper;
import org.darkforest.model.OrderStatistics;
import org.darkforest.model.SellGoodsStatistics;
import org.darkforest.model.StatOrderGoods;
import org.darkforest.vo.MemberConsumptionStatisticVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/12/9.
 */
@Service
public class StatOrderGoodsServiceImpl implements StatOrderGoodsService {

    @Autowired
    private StatOrderGoodsMapper statOrderGoodsMapper;

    @Autowired
    private StatisticsEntryMapper statisticsEntryMapper;

    @Autowired
    private OrderStatisticsMapper orderStatisticsMapper;


    public int insert(StatOrderGoods record) {
        return statOrderGoodsMapper.insert(record);
    }

    @Override
    public int insertSelective(StatOrderGoods record) {
        return statOrderGoodsMapper.insertSelective(record);
    }

    @Override
    public List<String> findYListByXList(List<String> xLists) {
        return statOrderGoodsMapper.findYListByXList(xLists);
    }

    @Override
    public List<StatOrderGoods> findYListByStortId(Integer storeId) {
        return statOrderGoodsMapper.findYListByStortId(storeId);
    }

    @Override
    public StatOrderGoods findstatisticalByStortId(Integer storeId) {
        return statOrderGoodsMapper.findstatisticalByStortId(storeId);
    }

    @Override
    public List<SellGoodsStatistics> findOrderGoodsForStatByStoreId(Integer storeId) {
        return statisticsEntryMapper.findOrderGoodsForStatByStoreId(storeId);
    }

    @Override
    public List<SellGoodsStatistics> findRecentlyOrderAmount(Integer storeId) {
        return statisticsEntryMapper.findRecentlyOrderAmount(storeId);
    }



    /**
     * 根据添加查询商品在某段时间内的销售情况
     *
     * @param sellGoodsStatistics
     * @return
     */
    @Override
    public SellGoodsStatistics findRecentlyGoodsSellByPage(SellGoodsStatistics sellGoodsStatistics) {
        sellGoodsStatistics.setResultList(statisticsEntryMapper.findRecentlyGoodsSellByPage(sellGoodsStatistics));

        return sellGoodsStatistics;
    }

    /**
     * 商品分析 热卖商品
     *
     * @param sellGoodsStatistics
     * @return
     */
    @Override
    public SellGoodsStatistics findHotGoodsRecently(SellGoodsStatistics sellGoodsStatistics) {
        sellGoodsStatistics.setResultList(statisticsEntryMapper.findHotGoodsRecently(sellGoodsStatistics));
        return null;
    }

    /**
     * 统计概览
     * @return
     */
    @Override
    public OrderStatistics getAllOrderAmount() {
        return orderStatisticsMapper.getAllOrderAmount();
    }

    /**
     * 统计概览
     * @param days 天数
     * @return
     */
    @Override
    public OrderStatistics getAllOrderAmountLimit(int days) {
        return orderStatisticsMapper.getAllOrderAmountLimit(days);
    }

    /**
     * 统计概览
     * @return
     */
    @Override
    public OrderStatistics getAllGoodsCount() {
        return orderStatisticsMapper.getAllGoodsCount();
    }

    /**
     * 获取销售走势数据
     * @param days
     * @return
     */
    @Override
    public List<OrderStatistics> statisticAllOrder(int days) {
        return orderStatisticsMapper.statisticAllOrder(days);
    }

    /**
     * 统计概览
     * @param storeId 店铺编号
     * @return
     */
    @Override
    public OrderStatistics getOrderAmount(int storeId) {
        return orderStatisticsMapper.getOrderAmount(storeId);
    }

    /**
     * 统计概览
     * @param days 天数
     * @param storeId 店铺编号
     * @return
     */
    @Override
    public OrderStatistics getOrderAmountLimit(int days, int storeId) {
        Map map = new HashMap<String,Object>();
        map.put("days", days);
        map.put("stordId", storeId);
        return orderStatisticsMapper.getOrderAmountLimit(map);
    }

    /**
     * 统计概览
     * @param storeId 店铺编号
     * @return
     */
    @Override
    public OrderStatistics getGoodsCount(int storeId) {
        return orderStatisticsMapper.getGoodsCount(storeId);
    }

    /**
     * 获取销售走势数据
     * @param days
     * @param storeId 店铺编号
     * @return
     */
    @Override
    public List<OrderStatistics> statisticOrder(int days, int storeId) {
        Map map = new HashMap<String,Object>();
        map.put("days", days);
        map.put("stordId", storeId);
        return orderStatisticsMapper.statisticOrder(map);
    }

    /**
     * 会员消费统计
     *
     * @param record
     * @return
     */
    @Override
    public List<MemberConsumptionStatisticVo> getMemberConsumpStatisticInfo(MemberConsumptionStatisticVo record) {
        return orderStatisticsMapper.getMemberConsumpStatisticInfo(record);
    }


}
